//
//  NSDecimalNumber+NED.h
//  MoreCoin
//
//  Created by 林宁宁 on 2019/10/17.
//  Copyright © 2019 MoreCoin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSDecimalNumber (NED)

/*
typedef NS_ENUM(NSUInteger, NSRoundingMode) {
    NSRoundPlain,   // Round up on a tie(四舍五入)
    NSRoundDown,    // Always down == truncate(只舍不入)
    NSRoundUp,      // Always up(只入不舍)
    NSRoundBankers  // on a tie round so last digit is even(也是四舍五入,这是和NSRoundPlain不一样,如果精确的哪位是5,
它要看精确度的前一位是偶数还是奇数,如果是奇数,则入,偶数则舍,例如scale=1,表示精确到小数点后一位, NSDecimalNumber 为1.25时,
NSRoundPlain结果为1.3,而NSRoundBankers则是1.2),下面是例子:
};
 scale表示精确到小数点后几位,并且NSRoundingMode影响的也是scale位
*/

//+ (NSDecimalNumber *)ned_decimalNumberWithFloat:(float)value;
//+ (NSDecimalNumber *)ned_decimalNumberWithFloat:(float)value scale:(short)scale;
//+ (NSDecimalNumber *)ned_decimalNumberWithFloat:(float)value roundingMode:(NSRoundingMode)roundingMode scale:(short)scale;
//+ (NSDecimalNumber *)ned_decimalNumberWithDouble:(double)value;
//+ (NSDecimalNumber *)ned_decimalNumberWithDouble:(double)value scale:(short)scale;
//+ (NSDecimalNumber *)ned_decimalNumberWithDouble:(double)value roundingMode:(NSRoundingMode)roundingMode scale:(short)scale;
//
///**
// *  <#Description#>
// *
// *  @return <#return value description#>
// */
//- (NSDecimalNumber *)ned_decimalNumberHandler;
//- (NSDecimalNumber *)ned_decimalNumberHandlerWithRoundingMode:(NSRoundingMode)roundingMode scale:(short)scale;



/// 只舍不入 六位小数
+ (NSString *)ned_6_decimalDownStr:(NSString *)valueStr;
+ (NSString *)ned_6_decimalDownFloat:(CGFloat)value;
+ (NSString *)ned_6_decimalDownDecimal:(NSDecimal)valueDecimal;
+ (NSString *)ned_2_decimalDownStr:(NSString *)valueStr;
+ (NSString *)ned_2_decimalDownFloat:(CGFloat)value;
+ (NSString *)ned_2_decimalDownDecimal:(NSDecimal)valueDecimal;

+ (NSString *)ned_decimalWithValueStr:(NSString *)valueStr
                        roundingMode:(NSRoundingMode)roundingMode
                               scale:(NSInteger)scale;
+ (NSString *)ned_decimalWithValueDecimal:(NSDecimal)valueDecimal
                            roundingMode:(NSRoundingMode)roundingMode
                                   scale:(NSInteger)scale;


@end


@interface NSNumber (NEDDecimal)

/// 保留几位小数
@property (copy, nonatomic) NSString *(^ned_decimalDown)(NSInteger scale);
/// 最多保留几位小数
@property (copy, nonatomic) NSString *(^ned_decimalMax)(NSInteger maxScale);

- (NSString *)ned_decimalDown_6;
- (NSString *)ned_decimalDown_2;
- (NSString *)ned_decimalDown_0;

- (NSString *)ned_decimalUp_6;
- (NSString *)ned_decimalUp_2;

/// 最多两位小数
- (NSString *)ned_decimalMax_2;

@end

@interface NSString (NEDDecimal)

/// 保留几位小数
@property (copy, nonatomic) NSString *(^ned_decimalDown)(NSInteger scale);
/// 最多保留几位小数
@property (copy, nonatomic) NSString *(^ned_decimalMax)(NSInteger maxScale);


- (NSString *)ned_decimalDown_6;
- (NSString *)ned_decimalDown_2;

/// 最多两位小数
- (NSString *)ned_decimalMax_2;

/// 利息收益的千分位显示保留2位小数 如果没有小数会自动补0
- (NSString *)ned_thousandsTwoDecimals;
/// 最多两位小数
- (NSString *)ned_thousandsMoreTwoDecimals;

/// 千分位显示
- (NSString *)ned_thousands;

@end

NS_ASSUME_NONNULL_END
